package com.hk.developmentlib.view.itemdecoration;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.hk.developmentlib.utills.DeviceUtils;


/**
 * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
 */
public class VideoItemDecoration extends RecyclerView.ItemDecoration {
    private int space;

    public VideoItemDecoration(Context ct, int space) {

        this.space = DeviceUtils.dip2px(ct, space);
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {

        outRect.top = 2 * space;
        outRect.bottom = 2 * space;
        outRect.left =  space/2;
        outRect.right = space/2;

        if (parent.getChildAdapterPosition(view) + 1 == parent.getAdapter().getItemCount()) {
            outRect.right = space*2;
        } else if (parent.getChildAdapterPosition(view) == 0) {
            outRect.left =  space*2;
        }


    }
}
